package org.builder.main;

import org.annotation.ExcelColumn;
import org.builder.excel.*;
import org.pojo.TimeSegmentCustomerFlowAnalysisBean;
import org.util.MethodUtils;
import org.util.ObjectUtils;

import java.lang.reflect.Method;
import java.util.*;

/**
 * @author huangshen
 * @version 0
 * @description Test2
 * @since 2022/2/9 14:13
 */
public class XSFTest1 {

    public static void main(String[] args) throws Exception{
        List<TimeSegmentCustomerFlowAnalysisBean> beanList = new ArrayList<>();
        Class<TimeSegmentCustomerFlowAnalysisBean> targetClass = TimeSegmentCustomerFlowAnalysisBean.class;

        List<Method> methodList = new MethodUtils(targetClass).getSetMethodListByAnnotation(ExcelColumn.class);
        int i = 1000;
        TimeSegmentCustomerFlowAnalysisBean bean = new TimeSegmentCustomerFlowAnalysisBean();
        while (i > 0) {
            TimeSegmentCustomerFlowAnalysisBean clone = (TimeSegmentCustomerFlowAnalysisBean) bean.clone();
            for (Method method : methodList) {
                method.invoke(clone, "1");
            }
            i--;
            beanList.add(clone);
        }

        List<Map<String, Object>> maps = ObjectUtils.transformBeanToMap(beanList);
        String exportPath = "C:/Users/gugu/Desktop/test1/" +new Random().nextInt() + ".xlsx";

        long start1 = System.currentTimeMillis();
        ExcelDirector director = new ExcelDirector(new NormalExcelFastXSFImp());
        BaseExcelExportBuild normalExcel = director.createNormalExcel1(exportPath, targetClass, maps);
        normalExcel.createExcel();
        long end1 = System.currentTimeMillis();

        System.out.println("method one use time:" + (end1 - start1));
    }
}
